#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>

void main()
{
	int fd2 = open("1.txt",O_WRONLY);

	struct flock ltype;
	ltype.l_type = F_WRLCK;
	ltype.l_start = 0;
	ltype.l_whence = SEEK_SET;
	ltype.l_len = 0;

	printf("start wrlck\n");

	fcntl(fd2,F_SETLKW,&ltype);
	printf("wrlck success\n");
	getchar();

	ltype.l_type = F_UNLCK;
	fcntl(fd2,F_SETLK,ltype);
	printf("unlock wrlocd\n");

	close(fd2);

}